home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-03 | 1.1 KB | 46 lines | [TEXT/R*ch] |
- (* Mosml -- Moscow ML specific functions *)
-
- local
- prim_val argv_ : string Vector.vector = 0 "command_line";
- in
-
- fun argv () =
- let fun h i res =
- if i >= 0 then h (i-1) (Vector.sub(argv_, i) :: res)
- else res
- in h (Vector.length argv_ - 1) [] end;
-
- (* Requires Time and Timer to be loaded *)
-
- fun time f arg =
- let open Timer
- val cputimer = startCPUTimer ()
- val realtimer = startRealTimer ()
- fun report () =
- let val {usr, sys, gc} = checkCPUTimer cputimer;
- val rea = checkRealTimer realtimer;
- fun format t = Time.toString t
- open BasicIO
- in say("User: " ^ format usr ^
- " System: " ^ format sys ^
- " GC: " ^ format gc ^
- " Real: " ^ format rea ^ "\n")
- end
- fun x before y = x
- in
- (f arg before report ())
- handle e => (report (); raise e)
- end;
-
- fun listDir path =
- let open FileSys
- val dir = openDir path
- fun read "" res = res
- | read f res = read (readDir dir) (f :: res)
- val files = read (readDir dir) []
- in closeDir dir; files end
- handle exn as OS.SysErr (msg, _) => (BasicIO.say msg; raise exn)
-
- end (* local *)
-
-